package com.zhht.checkcop.log.util;

import com.zhbc.framework.utils.StringUtils;
import com.zhbc.framework.utils.SysConfig;
/**
 * 存放通用的常量
 * @author ningquan
 *
 */
public class Constant {
	
	public static final String SUCCESS="success";
	public static final String ERROR="error";
	public static final String EMPTY_STRING="";
	public static final String SIGNATURE = "signature";
	public static final String LOCK_TAG = "1";
	public static final String ZKEY = "zkey";
	
	public static final String ZKEY_VALUE = "zhihuihutong";
	
	public static final String STR_AND = "&";
	
	public static final String STR_EQUAL = "=";
	
	public  static String FILE_SEPARATOR="/";
	
	public static final String DELIMETER="_";
	
	public static final String MIDDLE_DELIMETER="-";
	
	public static final String FORMAT="{}";
	
	public static final String YES="yes";
	
	public static final String NO="no";
	
	public static final String ON="on";
	
	public static final String OFF="off";
	
	public static final String IMAGE_PATH = SysConfig.getString("rs.park.image.path");
	
	public static final String FULL = "full";
	
	public static final String FEATURE = "feature";
	
    public static final String FULL2 = "full2";
	
	public static final String FEATURE2 = "feature2";
	
	public static final String PLATE = "plate";
	
	public static final String IMG_SUFFIX_JPG=".jpg";
	public static final String IMG_SUFFIX_GIF=".gif";
	public static final String IMG_SUFFIX_PNG=".png";
	public static final String IMG_SUFFIX_BMP=".bmp";
	public static final String DATE_FMT = "yyyy-MM-dd HH:mm:ss";
	public static final String LOG_TRACE_PARAM="traceId";
	public static final String LOG_TRACE_ID_RULE="{0}-{1}-{2}-{3}";//app-inf-date-uuid;eg:sjz.aipark.com-park-2017-01-01 23:12:45-uuid
	
	//图片目录
	public static final String PATH_REALTIME_PICTURE="/realtime/";
	public static final String PATH_FULL_PICTURE="/full/";
	public static final String PATH_FEATURE_PICTURE="/feature/";
	public static final String PATH_BUSY_PICTURE="/busy/";
	public static final String PATH_MEMBER_PICTURE="/member/";
	public static final String PATH_PARK_PICTURE="/park/";
	public static final String PATH_BERTHLINE_PICTURE="berthline/";
	public static final String PATH_ORIGIN_PICTURE="/origin/";
	
	/**
	 * 文件存储方式
	 */
	public static  int FILE_STORAGE_WAY = SysConfig.getInt("fileStorageWay");
	
	/**
	 * 文件访问服务接口名称
	 */
	public static  String DFS_SERVICEINF_NAME = SysConfig.getString("dfsServiceInfName");
	
	/**替换消息正则 
	 * @author ningquan
	 * */
	public static final String REPLACE_MSG_REGEX = "\\{(\\s*(\\d+)\\s*)\\}";
	
	/**
	 *二次车牌识别结果 ningquan
	 */
	public static  String SECOND_OCR_SWITCH=SysConfig.getString("SWITCH_SECOND_OCR");
	public static  boolean IS_SECOND_OCR = getIsSecondOcr();
	/**
	 * OSS访问配置ningquan
	 */
//	public static  String PARK_IMG_CLIENT_R_DOMAIN=BucketName.BUSINESS_IMG.getImgDomain();
	public static  String OSS_ENDPOINT=SysConfig.getString("oss.bucket.name.Endpoint");
	public static  String OSS_ACCESS_KEY_ID=SysConfig.getString("oss.AccessKeyId");
	public static  String OSS_ACCESS_KEY_SECRET=SysConfig.getString("oss.AccessKeySecret");
	/**
	 * 一卡通缴费city_Id
	 */
	public static  String ONE_CARD_CITY_IDS=SysConfig.getString("one_card_charge_city");
	
	/**
	 * 选择全部
	 */
	public static final String SELECT_ALL_CODE="-1";
	/**
	 * 二次识别算法请求地址
	 */
	public static  String SECOND_OCR_URL=SysConfig.getString("second_ocr_url");
	/**
	 * 手动确认开关
	 */
	public static  String MANUAL_SURE_SWITCH=SysConfig.getString("SWITCH_MANUAL_SURE");
	
	public static  String EQUIPEXCP_WARN_SWITCH=SysConfig.getString("switch.equipExcp.warn");
	
	public static  String OCR_TO_AI_SWITCH=SysConfig.getString("switch.ocr.to.ai");
	/**业务图片上传拆分开关*/
	public static  String SEPARATE_DATA_IMAGE_SWITCH=SysConfig.getString("switch.separate.data.image");
	public static boolean IS_SEPARATE_DATA_IMAGE=getSwitchState(SEPARATE_DATA_IMAGE_SWITCH);
	public static  boolean IS_MANUAL_SURE = getSwitchState(MANUAL_SURE_SWITCH);

	/**
	 * 允许异常入场间隔分钟数
	 */
	public static Integer PARK_EXCP_ENTRY_GAP_MIN = SysConfig.getInt("park.excp.entry.gap.min");
	/**
	 * 允许异常出场间隔分钟数
	 */
	public static Integer PARK_EXCP_EXIT_GAP_MIN = SysConfig.getInt("park.excp.exit.gap.min");
	/**
	 * 停车最大间隔分钟数
	 */
	public static Integer PARK_MAX_GAP_MIN = SysConfig.getInt("park_max_gap_min");
	
	public static  String ALARM_MAIL_RECIVE=SysConfig.getString("common.mail.recive");
	public static  String ALARM_PHONE_RECIVE = SysConfig.getString("common.sms.recive");
	/**
	 * 项目发布平台
	 */
	public static  String PROJECT_PUBLISH_ENV=SysConfig.getProjectPublishEnv();
	
	/**
	 * 用户session超时时间
	 */
	public static final int USER_SESSION_TIMEOUT=1800;//秒
	/**
	 * 设备状态监测任务表达式
	 */
	public static final String EQUIPSTATUS_SCHEDULE_CRONEXP = SysConfig.getString("equipStatus.schedule.cronExp");
	public static final String OCR_RECORD_ID = "ocrRecordId";
	public static final String PLATE_IAMGE = "plateImage";
	public static final String PLATE_IAMGE2 = "plateImage2";
	public static final String FEATURE_IMAGE = "featureImage";
	public static final String FEATURE_IMAGE2 = "featureImage2";
	public static final String FULL_IMAGE = "fullImage";
	public static final String IS_MAIL_PARAM=SysConfig.getString("common.mail.switch");
	public static final boolean IS_MAIL = getSwitchState(IS_MAIL_PARAM);
	public static final String IS_SMS_PARAM=SysConfig.getString("common.sms.switch");
	public static final boolean IS_SMS = getSwitchState(IS_SMS_PARAM);
	/**
	 * 电子发票开关
	 */
	public static final String IS_INVOICE_PARAM=SysConfig.getString("common.invoice.switch");
	public static final boolean IS_INVOICE = getSwitchState(IS_INVOICE_PARAM);
	public static String  OS_TYPE=System.getProperties().getProperty("os.name").toLowerCase();
	public static boolean LIUX_OS = OS_TYPE.contains("linux")?true:false;
	public static final int PLATE_RELIABILITY_THRESHOLD=SysConfig.getInt("plate.reliability.threshold");
	public static final int EVENT_RELIABILITY_THRESHOLD=SysConfig.getInt("event.reliability.threshold");
	/**垂停入场自动化开关*/
	public static final String IDENTIFICATION_AUTO_ENTRY_SWITCH=SysConfig.getString("identification.auto.entry.switch");
	/**垂停出场自动化开关*/
	public static final String IDENTIFICATION_AUTO_EXIT_SWITCH=SysConfig.getString("identification.auto.exit.switch");
	/**枪球入场自动化开关*/
	public static final String VIDEO_AUTO_ENTRY_SWITCH=SysConfig.getString("video.auto.entry.switch");
	/**枪球出场自动化开关*/
	public static final String VIDEO_AUTO_EXIT_SWITCH=SysConfig.getString("video.auto.exit.switch");
	
	public static final int PLATE_MATCH_NUM=SysConfig.getInt("plate.match.num");
	public static final String  ACREAGE=SysConfig.getString("witdh_multiply_high");
	public static final String  SCALE=SysConfig.getString("witdh_divide_high");
	
	//G2GPLUS数据同步不开关     #on|off
	public static final String  SJZ_G2GPLUS_ON_OFF=SysConfig.getString("sjz.g2gplus").trim();
	
	/**
	 * 大额欠费功能：采用配置文件添加默认大额欠费阈值暂定为500
	 * 当缓存获取不到阈值时从配置文件里获取默认值
	 */
	public static final String LACKMONEY_THRESHOLD=SysConfig.getString("lackmoney.threshold");
	
	/**
	 * 是否允许设备告警
	 * @return
	 */
	public static boolean isAllowEquipWarn(){
		if(StringUtils.isNotStrTrimNull(EQUIPEXCP_WARN_SWITCH) && EQUIPEXCP_WARN_SWITCH.equals(ON)){
			return true;
		}
		return false;
	}
	
	
	/**
	 * 是否允许调用蓝脑服务
	 * @return
	 */
	public static boolean isAllowToAI(){
		if(StringUtils.isNotStrTrimNull(OCR_TO_AI_SWITCH) && OCR_TO_AI_SWITCH.equals(ON)){
			return true;
		}
		return false;
	}
	
	public static boolean getSwitchState(String switchVal) {
		if(StringUtils.isStrTrimNull(switchVal)){
			return false;
		}
		if(switchVal.equalsIgnoreCase(ON)){
			return true;
		}
		return false;
	}

	static{
		if(PARK_MAX_GAP_MIN == null || PARK_MAX_GAP_MIN==0){
			PARK_MAX_GAP_MIN = 480;
		}
	}
	
	private static boolean getIsSecondOcr() {
		if(SECOND_OCR_SWITCH == null){
			return false;
		}
		if(SECOND_OCR_SWITCH.equalsIgnoreCase("on")){
			return true;
		}
		return false;
	}

	
	private static String getPubConfig(){
		String config = PROJECT_PUBLISH_ENV.substring(PROJECT_PUBLISH_ENV.indexOf(".")+1);
		if(StringUtils.isStrTrimNull(config)){
			throw new IllegalArgumentException("project publish environment have question,please check your config file!");
		}
		return config;
	}

}
